#include <bits/stdc++.h>
using namespace std;
#define int long long
typedef pair<int, int> PII;
const int N = 100010;
int T, n, m, L, V;
int d[N], v[N], a[N], p[N];
pair<int,int> rush[N];/*
bool cmp(double x, double y)
{
    if (fabs(x - y) < 1e-8) return true;
    if (x < y) return true;
    return false;
}*/
bool check(int car, int pos)
{
    int curv = v[car] * v[car] + 2 * a[car] * (p[pos] - d[car]);

    //cout << curv << endl;
    return curv > V * V;
}
bool cmp2(const PII& _1, const PII& _2) {
    return _1.second < _2.second;
}
void solve() {
    cin >> n >> m >> L >> V;
    for (int i = 1; i <= n; i ++ )
        cin >> d[i] >> v[i] >> a[i];
    for (int i = 1; i <= m; i ++ ) cin >> p[i];
    sort(p + 1, p + m + 1);
    //cout << check(5, 5) << endl;
    //return ;
    int res = 0;
    for (int i = 1; i <= n; i ++ )
    {
        int l = 1, r = m, pos = m + 1;
        while (l <= r)
        {
            int mid = l + r >> 1;
            if (p[mid] >= d[i]) pos = mid, r = mid - 1;
            else l = mid + 1;
        }
        if (pos == m + 1) continue;
        assert(p[pos]>=d[i]);
        if (a[i] > 0) {
            int l = pos, r = m, bd = -1;
            if (!check(i, m)) continue;
            while (l <= r)
            {
                int mid = l + r >> 1;
                if (check(i, mid)) r = mid - 1, bd = mid;
                else l = mid + 1;
            }
            rush[ ++ res] = {bd, m};
            //if (bd==9) {
            //    cout<<i<<endl;
            //}
        }
        else {
            int l = pos, r = m, bd = -1;
            if (!check(i, pos)) continue;
            while (l <= r) {
                int mid = l + r >> 1;
                if (check(i, mid)) l = mid + 1, bd = mid;
                else r = mid - 1;
            }
            if (bd == -1) continue;
            rush[ ++ res] = {pos, bd};
        }
        //cout << i << " " << rush[i].first] << " " << p[rush[i].second] << endl;
    }
    cout << res << " ";
    sort(rush + 1, rush + res + 1, cmp2);
    int sum = 0, maxn = 0;
    for (int i = 1; i <= res; i ++ )
    {
         //cout << rush[i].first << " " << rush[i].second << endl;
        if (maxn >= rush[i].first) ;
        else {
            maxn = max(maxn, rush[i].second);
            sum ++ ;
        }
    }
    // cout<<sum<<"\n";
    cout << m - sum << "\n";
}
signed main() {
    freopen("detect.in", "r", stdin);
    freopen("detect.out", "w", stdout);
    ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
    cin >> T;
    while (T -- ) solve();
    return 0;
}
